package com.code.leetcode.before50;

import com.code.leetcode.utils.Node;

import java.util.ArrayList;
import java.util.List;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/24 20:26
 */
public class The589 {

    ArrayList<Integer> list = new ArrayList<Integer>();

    public List<Integer> preorder(Node root) {
        dfs(root);
        return list;
    }

    public void dfs(Node node) {
        if (node == null) return;
        list.add(node.val);
        for (int i = 0; i < node.children.size(); i++) {
            dfs(node.children.get(i));
        }
    }

}
